Ensure constant beam count for ROS2 SLAM Toolkit and Nav2 to work - #3
Open
slgrobotics wants to merge 2 commits into
Open
Ensure constant beam count for ROS2 SLAM Toolkit and Nav2 to work#3slgrobotics wants to merge 2 commits into
slgrobotics wants to merge 2 commits into
Conversation
fixing Ubuntu 24.04 compile error
ensure the beam count is constant between LIDAR head revolutions
Author
|
See also #2 for the |
|
@slgrobotics, thank you for your contribution. This fix resolved the issue I was experiencing. Previously, no matter how I configured slam_toolbox, I couldn't get proper mapping results—the output was either missing or very strange, and adjusting the slam_toolbox parameters didn't help. After checking the logs and noticing the error: "LaserRangeScan contains 398 range readings, expected 399", I came to this repository and immediately found your solution. Great work! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am using LD14 device with the following launch description:
The "demo.cpp" code passes each LIDAR head rotation "beams vector" as it comes from the driver, with the beam count dependent on the head rotation speed. In my case, the beam count varies in the range 388...393, so that the "/scan" topic is also containing variable point count. ROS2 Jazzy SLAM Toolbox treats this as error - it expects all incoming messages to contain the same amount of points.
To fix that, I added code to measure an average of 20 first valid scans (first scan is skipped as it always comes truncated), and to resize the resulting "scan vector" to that average size (if it needs expanding in the process, the last element is used to fill the void). So, all messages come to ROS2 with the same point count.
The modification is tested on Raspberry Pi 5 under Ubuntu 24.04 and ROS2 Jazzy. SLAM Toolbox and Nav2 works fine now.
More detail about that robot is here: https://github.com/slgrobotics/robots_bringup/blob/main/Docs/Dragger/README.md